package huoye.shops.huoye.operation.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.codeideology.android.lang.entity.Paging;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import huoye.shops.base.BaseActivity;
import huoye.shops.base.PullToRefreshFragment;
import huoye.shops.huoye.operation.model.PrizeCancelData;
import huoye.shops.huoye.operation.adapter.PrizeCancelAdapter;
import huoye.shops.huoye.operation.presenter.PrizeCancelPresenter;
import huoye.shops.huoye.operation.view.IPrizeCancelRefreshView;


public class PrizeCancelFragment extends PullToRefreshFragment<PrizeCancelData> implements IPrizeCancelRefreshView {

    public static final int TYPE_PRIZE_CANCEL_NO  = 0; //未核销
    public static final int TYPE_PRIZE_CANCEL_YES = 1; //已核销
    public static final int TYPE_PRIZE_CANCEL_LOSE = 2; //已失效


    private int mType;
    private PrizeCancelPresenter mPrizeCancelPresenter;

    @Override
    public RecyclerViewAdapter createAdapter() {

        Bundle bundle = getArguments();
        mType = bundle.getInt(BaseActivity.EXTRAS_KEY_DATA);
        PrizeCancelAdapter adapter = new PrizeCancelAdapter(getActivity());

        return adapter;
    }


    @Override
    protected void initView(View view, @Nullable Bundle bundle) {
        super.initView(view, bundle);

        mPrizeCancelPresenter = new PrizeCancelPresenter();
        mPrizeCancelPresenter.addTaskListener(this);
        mPrizeCancelPresenter.onStart();
        query();

    }





    @Override
    public void query(Paging paging) {
        super.query(paging);
        mPrizeCancelPresenter.getPrizeCancelList(mType+"",paging);
    }


    public static PrizeCancelFragment getInstan(int type) {
        PrizeCancelFragment fragment = new PrizeCancelFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(BaseActivity.EXTRAS_KEY_DATA, type);
        fragment.setArguments(bundle);
        return fragment;

    }





    @Override
    public void onItemClick(PrizeCancelData prizeCancelData, int i, View view) {

    }
}
